Surface server-side failures and receive errors in sync JSON output#41
Merged
Surface server-side failures and receive errors in sync JSON output#41
Conversation
Propagate server-reported lastFailure through cloudsync_network_send_changes and cloudsync_network_sync output. Capture receive-phase errors (including cloudsync_payload_apply failures like unknown schema hash) and emit them as a structured receive.error field in cloudsync_network_sync instead of raising a SQL error that would hide the successful send result. cloudsync_network_check_changes keeps the error-raising behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The err_out path in network_download_changes and cloudsync_network_check_internal was treating all non-BUFFER responses as errors, including CLOUDSYNC_NETWORK_OK which is the normal "no changes ready yet" response. This caused the retry loop in cloudsync_network_sync to break immediately on the first empty check response instead of retrying, resulting in receive.rows always being 0. Now only CLOUDSYNC_NETWORK_ERROR sets err_out; CLOUDSYNC_NETWORK_OK returns rc=0 so the retry loop continues as expected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Refine the error-handling contract: endpoint/network errors (server unreachable, auth failure) always raise a SQL error regardless of which function is called. Only cloudsync_payload_apply failures are surfaced as structured JSON via receive.error. cloudsync_network_check_changes now also returns receive.error in JSON for apply failures (consistent with sync), instead of raising a SQL error for those. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
server rejected an apply job.
to all three sync functions (cloudsync_network_send_changes, cloudsync_network_check_changes, cloudsync_network_sync).
the server was reachable.
Test plan